package com.example.dongha.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;


import com.example.dongha.R;

import java.util.List;


/**
 * Created by liangkun on 2018/4/13.
 * 作用: 我的设备one适配器
 */

public class CountRecyclerAdapter extends RecyclerView.Adapter<CountRecyclerAdapter.CoolRecyclerHolder> implements View.OnClickListener {
    private List<String> beanList;
    private Context context;

    public CountRecyclerAdapter(Context context, List<String> datas) {
        this.beanList = datas;
        this.context = context;
    }

    @Override
    public CoolRecyclerHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(context).inflate(R.layout.item_count_list, parent, false);
        CoolRecyclerHolder recyclerHolder = new CoolRecyclerHolder(view);
        view.setOnClickListener(this);
        return recyclerHolder;
    }

    @Override
    public void onBindViewHolder(CoolRecyclerHolder holder, int position) {
        holder.tv.setText(beanList.get(position));
    }

    @Override
    public int getItemCount() {
        return beanList.size();
    }

    @Override
    public void onClick(View v) {


    }

    public class CoolRecyclerHolder extends RecyclerView.ViewHolder {
        ImageView one;
        ImageView two;
        TextView tv;

        public CoolRecyclerHolder(View itemView) {
            super(itemView);
            one = itemView.findViewById(R.id.iv_one);
            two = itemView.findViewById(R.id.iv_two);
            tv = itemView.findViewById(R.id.tv_dec);
        }
    }

    public interface OnRecyclerViewItemClickListener {
        void onItemClick(int position, String type);
    }

    public OnRecyclerViewItemClickListener mOnItemClickListener = null;

    public void setOnItemClickListener(OnRecyclerViewItemClickListener listener) {
        this.mOnItemClickListener = listener;
    }

//    public void setDatas(List<FunctionShowBean> datas) {
//        notifyDataSetChanged();
//    }
}
